package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysLecturerGetPageReq struct {
	dto.Pagination  `search:"-"`
	Name            string `form:"name" search:"type:contains;column:name;table:sys_lecturer" comment:"讲师姓名"`
	TeachingType    string `form:"teaching_type" search:"type:exact;column:teaching_type;table:sys_lecturer" comment:"任教类型"`
	TeachingSubject string `form:"teaching_subject" search:"type:exact;column:teaching_subject;table:sys_lecturer" comment:"任教科目"`
	IsTop           int    `form:"is_top" search:"type:exact;column:is_top;table:sys_lecturer" comment:"是否置顶,是否在app显示"`
	SysLecturerOrder
	DeptJoin `search:"type:left;on:dept_id:dept_id;table:sys_lecturer;join:sys_dept"`
}

type SysLecturerOrder struct {
	IdOrder        int    `search:"type:order;column:id;table:sys_lecturer" form:"id_sort"`
	IsTopOrder     int    `search:"type:order;column:is_top;table:sys_lecturer" form:"is_top_sort"`
	CreatedAtOrder string `search:"type:order;column:created_at;table:sys_lecturer" form:"created_at_sort"`
	UpdatedAtOrder string `search:"type:order;column:updated_at;table:sys_lecturer" form:"updated_at_sort"`
}

func (m *SysLecturerGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysLecturerInsertReq struct {
	Id                     int    `json:"id" comment:"主键ID"`
	TeacherNumber          string `json:"teacher_number" comment:"教师编号" vd:"@:len($)>0; msg:'输入讲师编号'"`
	UserId                 int    `json:"user_id" comment:"用户ID" vd:"$>0; msg:'请选择需要绑定的用户'"`
	Name                   string `json:"name" comment:"教师姓名" vd:"@:len($)>0; msg:'讲师名称不能为空'"`
	TelPhone               string `json:"tel_phone" comment:"教师联系电话" vd:"@:len($)>0; msg:'教师联系电话不能为空'"`
	TeachingSubject        string `json:"teaching_subject" comment:"任教科目" vd:"@:len($)>0; msg:'请选择任教科目'"`
	TeachingType           string `json:"teaching_type" comment:"任教类型" vd:"@:len($)>0; msg:'请选择任教类型'"` //网课 线下授课
	Avatar                 string `json:"avatar" comment:"头像" vd:"@:len($)>0; msg:'请上传讲师形象'"`
	IsTop                  int    `json:"is_top" comment:"是否置顶"`
	GraduatedFrom          string `json:"graduated_from" comment:"毕业院校" vd:"@:len($)>0; msg:'请填写毕业院校'"`
	TeachingExperience     string `json:"teaching_experience" comment:"教学经历" vd:"@:len($)>0; msg:'请填写教学经历'"`
	TeachingCharacteristic string `json:"teaching_characteristic" comment:"教学特点" vd:"@:len($)>0; msg:'请填写教学特点'"`
	Introduction           string `json:"introduction" comment:"课程简介" vd:"@:len($)>0; msg:'班级名称不能为空'"` //简介
	Label                  string `json:"label" comment:"标签"`
	DeptId                 int    `json:"dept_id" gorm:"type:int(5);comment:所属部门ID"`
	TeachingPointId        int    `json:"teaching_point_id" gorm:"type:int(10);comment:所属教学点id"`
	common.ControlBy
}

func (s *SysLecturerInsertReq) Generate(model *models.SysLecturer) {
	//model.CourseId = s.CourseId
	model.UserId = s.UserId
	model.TeacherNumber = s.TeacherNumber
	model.Name = s.Name
	model.TelPhone = s.TelPhone
	model.TeachingType = s.TeachingType
	model.TeachingSubject = s.TeachingSubject
	model.Avatar = s.Avatar
	model.IsTop = s.IsTop
	model.Introduction = s.Introduction
	model.TeachingCharacteristic = s.TeachingCharacteristic
	model.TeachingExperience = s.TeachingExperience
	model.GraduatedFrom = s.GraduatedFrom
	model.Label = s.Label
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
	model.DeptId = s.DeptId
	model.TeachingPointId = s.TeachingPointId
}

func (s *SysLecturerInsertReq) GetId() interface{} {
	return s.Id
}

type SysLecturerUpdateReq struct {
	Id                     int    `json:"id" comment:"主键ID"`
	UserId                 int    `json:"user_id" comment:"用户ID" vd:"$>0; msg:'请选择需要绑定的用户'"`
	TeacherNumber          string `json:"teacher_number" comment:"教师编号" vd:"@:len($)>0; msg:'输入讲师编号'"`
	Name                   string `json:"name" comment:"教师姓名" vd:"@:len($)>0; msg:'讲师名称不能为空'"`
	TelPhone               string `json:"tel_phone" comment:"教师联系电话" vd:"@:len($)>0; msg:'教师联系电话不能为空'"`
	TeachingSubject        string `json:"teaching_subject" comment:"任教科目" vd:"@:len($)>0; msg:'请选择任教科目'"`
	TeachingType           string `json:"teaching_type" comment:"任教类型" vd:"@:len($)>0; msg:'请选择任教类型'"` //网课 线下授课
	Avatar                 string `json:"avatar" comment:"头像" vd:"@:len($)>0; msg:'请上传讲师形象'"`
	IsTop                  int    `json:"is_top" comment:"是否置顶"`
	GraduatedFrom          string `json:"graduated_from" comment:"毕业院校" vd:"@:len($)>0; msg:'请填写毕业院校'"`
	TeachingExperience     string `json:"teaching_experience" comment:"教学经历" vd:"@:len($)>0; msg:'请填写教学经历'"`
	TeachingCharacteristic string `json:"teaching_characteristic" comment:"教学特点" vd:"@:len($)>0; msg:'请填写教学特点'"`
	Introduction           string `json:"introduction" comment:"课程简介" vd:"@:len($)>0; msg:'班级名称不能为空'"` //简介
	Label                  string `json:"label" comment:"标签"`
	DeptId                 int    `json:"dept_id" gorm:"type:int(5);comment:所属教学点ID"`
	TeachingPointId        int    `json:"teaching_point_id" gorm:"type:int(10);comment:所属教学点id"`
	common.ControlBy
}

func (s *SysLecturerUpdateReq) Generate(model *models.SysLecturer) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.UserId = s.UserId
	model.TeacherNumber = s.TeacherNumber
	model.Name = s.Name
	model.TelPhone = s.TelPhone
	model.TeachingType = s.TeachingType
	model.TeachingSubject = s.TeachingSubject
	model.Avatar = s.Avatar
	model.IsTop = s.IsTop
	model.TeachingCharacteristic = s.TeachingCharacteristic
	model.TeachingExperience = s.TeachingExperience
	model.GraduatedFrom = s.GraduatedFrom
	model.Introduction = s.Introduction
	model.Label = s.Label
	model.DeptId = s.DeptId
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
	model.TeachingPointId = s.TeachingPointId
}

func (s *SysLecturerUpdateReq) GetId() interface{} {
	return s.Id
}

type SysLecturerById struct {
	dto.ObjectById
	common.ControlBy
}

type SysLecturerUpdateTopStatusReq struct {
	Id    int `json:"id" comment:"更新ID" vd:"$>0; msg:'更新ID不能为空'"`
	IsTop int `json:"is_top" comment:"置顶状态"`
	common.ControlBy
}

func (s *SysLecturerUpdateTopStatusReq) Generate(model *models.SysLecturer) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.IsTop = s.IsTop
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
}

type SysLecturerSearchReq struct {
	Name string `form:"name" search:"type:contains;column:name;table:sys_class" comment:"根据班主任名称搜索关键字"`
}

func (m *SysLecturerSearchReq) GetNeedSearch() interface{} {
	return *m
}

type SysLecturerUpdateStatusReq struct {
	IsTop      int `json:"is_top" comment:"置顶状态"`
	LecturerId int `json:"lecturer_id" comment:"讲师ID" vd:"$>0; msg:'讲师ID不能为空'"`
	common.ControlBy
}

func (s SysLecturerUpdateStatusReq) Generate(model *models.SysLecturer) {
	model.IsTop = s.IsTop
}

func (s SysLecturerUpdateStatusReq) GetId() int {
	return s.LecturerId
}
